﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace nplJobsDAL.Insert
{
    public class InsertJobLocationWithin : DataAccessBase
    {
        public long JobId;
        public int DivisionId;
        public int DistrictId;
        public int CityId;

        public InsertJobLocationWithin()
        {
            StoredProcedureName = StoredProcedure.Name.spInsertJobLocationWinthin.ToString();
        }

        public void Insert()
        {
            InsertJobLocationWithinParameters parameters = new InsertJobLocationWithinParameters(this.JobId, this.DivisionId, this.DistrictId, this.CityId);
            DataBaseHelper dbHelper = new DataBaseHelper(StoredProcedureName);
            dbHelper.Parameters = parameters.Parameters;
            object LastJobSeekerProfessionalInfoID = dbHelper.RunScalar();
        }
    }

    #region SQL parameters for Location info data parameters
    public class InsertJobLocationWithinParameters
    {
        private long _JobId;
        private int _DivisionId;
        private int _DistrictId;
        private int _CityId;
        private SqlParameter[] _parameters;

        public InsertJobLocationWithinParameters(long JobId, int DivisionId, int DistrictId, int CityId)
        {
            this._JobId = JobId;
            this._DivisionId = DivisionId;
            this._DistrictId = DistrictId;
            this._CityId = CityId;
            Build();
        }

        private void Build()
        {
            SqlParameter[] parameters = 
                {
                    new SqlParameter("@JobID", _JobId),
                    new SqlParameter("@DivisionId", _DivisionId),
                    new SqlParameter("@DistrictId", _DistrictId),
                    new SqlParameter("@CityId", _CityId)
                };

            Parameters = parameters;
        }

        public SqlParameter[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }
    }
    #endregion
}
